#!/bin/sh
#
# Some of the logic of this should look familiar, it was shamelessly
# cut and pasted from marcusmerge and kdemerge.
#
# This was written to perform a sparse checkout of the ports tree
# based on the contents of area51. You can tweak the _pcvs line
# to point to your favourite repo/mirror.
#
# Be aware this will checkout files to your current working directory.
#
# Feedback to tabthorpe@FreeBSD.org is always welcome

_pcvs="cvs -d ${USER}@pcvs.FreeBSD.org:/home/pcvs"

KDEDIR="/home/area51" # aim at your area51 tree
KDEDIR=`/bin/realpath ${KDEDIR}`

for categorypath in `find ${KDEDIR} -type d -depth 1`; do
  category=$(basename "$categorypath")

  if [ ${category} = ".svn" ]; then
        continue
  fi

  for port in `ls -1 ${KDEDIR}/${category}`; do
    if [ ${port} = ".svn" ]; then
            continue
    fi
    echo "cvs co ${category}/${port}"
    ${_pcvs} co ports/${category}/${port}
  done
done
